package com.inspector.app.ui.base

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.gyf.immersionbar.ImmersionBar
import com.example.commen.interf.IBaseActivity
import com.example.commen.view.WaitDialog
import com.hjq.http.listener.OnHttpListener
import com.inspector.app.di.util.UI.makeStatusBarTransparent

import dagger.hilt.android.AndroidEntryPoint
import okhttp3.Call

@AndroidEntryPoint
open class BaseDJActivity : AppCompatActivity(), IBaseActivity {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        initStatusBar(true)
//        makeStatusBarTransparent(true)
    }

    /**
     * Boolean状态栏字体是深色，不写默认为亮色
     * 沉浸式
     */
    fun initStatusBar(boolean: Boolean) {
        ImmersionBar.with(this)
            .statusBarDarkFont(boolean)
            .keyboardEnable(false)
            .init()
    }


    override fun onStart() {
        super.onStart()
        try {
            initData()
            initListener()
        } catch (e: Exception) {
            e.printStackTrace()
        }

    }

    override fun initListener() {
    }

    override fun initData() {
    }


    private var dialog: WaitDialog.Builder? = null
    fun showProgress(message: String?) {
        if (isDestroyed) {
            return
        }
        if (dialog == null || !dialog?.isShowing()!!) {
            dialog = WaitDialog.Builder(this).setMessage(message)
            dialog!!.show()
        }
    }

    fun dismissProgress() {
        if (dialog?.isShowing() == true) {
            dialog!!.dismiss()
        }
    }
}
